'use strict';

module.exports = app => {
  const { STRING, FLOAT, INTEGER, JSON, BOOLEAN, UUID } = app.Sequelize;

  const Order = app.model.define('user', {
    id: { type: UUID, primaryKey: true },
    price: { type: FLOAT, allowNull: false },
    phone: { type: STRING, allowNull: false },
    start: { type: STRING, allowNull: false },
    end: { type: STRING, allowNull: false },
    points: { type: JSON, allowNull: false },
    startTime: { type: INTEGER, allowNull: false },
    capacity: { type: INTEGER, allowNull: false },
    full: { type: BOOLEAN, default: false },
  });

  Order.associate = function () {
    // hasMany  belongTo
    app.model.Order.hasOne(app.model.User, {
      foreignKey: 'UserId',
      targetKey: 'id'
    })
  }
}
